import QtQuick 2.12
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.12
import QtQuick.Controls 2.13

ColumnLayout {
    Layout.fillHeight: true
    Layout.fillWidth: true
    Component {
        id: tabButton
        TabButton {
            width: implicitWidth
        }
    }
    Component {
        id: resultListView
        Rectangle {
            anchors.fill: parent
            color: "green"
        }
    }
    SwipeView {
        id: tabBarLayout
        Layout.fillHeight: true
        Layout.fillWidth: true
        interactive: false
        currentIndex: 0
        LogArea {
            id: logArea
        }
    }
    TabBar {
        id: tabBar
        currentIndex: tabBarLayout.currentIndex
        Layout.fillWidth: true
        font.capitalization: Font.MixedCase
        TabButton {
            text: qsTr("log")
            width: implicitWidth
        }

        Connections {
            target: qmlBridge
            onLoadResultTab: {
                tabBar.addItem(tabButton.createObject(tabBar, {text: qsTr("search - " + term)}))
                tabBarLayout.addItem(resultListView.createObject())
                tabBarLayout.incrementCurrentIndex()
                console.log("Added new item...")
            }
        }
    }
}
